package com.darwin.darwinUI.general
{
//	import com.fminutes.vinciBase.App;
	
	import flash.text.TextField;
	
	/**
	 * 字体高级属性设置,主要用来设置是否为嵌入字体,以及嵌入后锯齿,网络,字体边缘清晰度的设置
	 */
	public class FontAdvProperties 
	{
		private var antiAliasType:String;
		private var gridFitType:String;
		private var sharpness:Number;
		private var thickness:Number;
		private var embedFonts:Boolean;
		
		/**
		 * 
		 * @param	embedFonts	是否使用嵌入字体
		 * @param	antiAliasType	消除锯齿类型(仅在embedFonts==true时有效)
		 * @param	gridFitType	网格固定类型(仅在embedFonts==true时有效)
		 * @param	sharpness	字型边缘清晰度(仅在embedFonts==true时有效)
		 * @param	thickness	字型边缘粗细(仅在embedFonts==true时有效)
		 */
		public function FontAdvProperties(embedFonts:Object = "nonuseEmbed", antiAliasType:String = "advanced", gridFitType:String = "pixel", sharpness:Number = 0, thickness:Number = 0) 
		{
			var $embedFonts:Boolean = false;
//			var currentLang:String = App.appLang;
			switch(embedFonts)
			{
				case DarwinFont.NONUSE_EMBED:
					$embedFonts = false;
					break;
				case DarwinFont.USE_EMBED:
					$embedFonts = true;
					break;
				/*case VinciFont.LANG_EMBED:
					if(VinciFont.INCLUDE_LANG_EMBED.indexOf(currentLang) == -1) $embedFonts = false;
					else $embedFonts = true;
					break;*/
				default:
					$embedFonts = (embedFonts == true);
					break;
			}
			
			this.embedFonts = $embedFonts;
			this.antiAliasType = antiAliasType;
			this.gridFitType = gridFitType;
			this.sharpness = sharpness;
			this.thickness = thickness;
		}
		
		/**
		 * 消除锯齿类型
		 * @return
		 */
		public function getAntiAliasType():String{
			return antiAliasType;
		}
		
		public function changeAntiAliasType(newType:String):FontAdvProperties{
			return new FontAdvProperties(embedFonts, newType, gridFitType, sharpness, thickness);
		}
		
		/**
		 * 网格固定类型
		 * @return
		 */
		public function getGridFitType():String{
			return gridFitType;
		}
		
		public function changeGridFitType(newType:String):FontAdvProperties{
			return new FontAdvProperties(embedFonts, antiAliasType, newType, sharpness, thickness);
		}
		
		/**
		 * 字型边缘的清晰度
		 * @return
		 */
		public function getSharpness():Number{
			return sharpness;
		}
		
		public function changeSharpness(newSharpness:Number):FontAdvProperties{
			return new FontAdvProperties(embedFonts, antiAliasType, gridFitType, newSharpness, thickness);
		}
		
		/**
		 * 字型边缘的粗细
		 * @return
		 */
		public function getThickness():Number{
			return thickness;
		}
		
		public function changeThickness(newThickness:Number):FontAdvProperties{
			return new FontAdvProperties(embedFonts, antiAliasType, gridFitType, sharpness, newThickness);
		}
		
		/**
		 * 是否为嵌入字体
		 * @return
		 */
		public function isEmbedFonts():Boolean	{
			return embedFonts;
		}
		
		public function changeEmbedFonts(embedFonts:Boolean):FontAdvProperties{
			return new FontAdvProperties(embedFonts, antiAliasType, gridFitType, sharpness, thickness);
		}
		
		/**
		 * 对传入的文本框进行高级设置
		 * @param	textField
		 */
		public function apply(textField:TextField):void	{
			textField.embedFonts = embedFonts;
			textField.antiAliasType = getAntiAliasType();
			textField.gridFitType = getGridFitType();
			textField.sharpness = getSharpness();
			textField.thickness = getThickness();
		}
		
		public function toString():String{
			return "FontAdvProperties[" 
			+ "embedFonts : " + embedFonts 
				+ ", antiAliasType : " + antiAliasType 
				+ ", gridFitType : " + gridFitType 
				+ ", sharpness : " + sharpness 
				+ ", thickness : " + thickness 
				+ "]";
		}
	}
}